package com.example.qxfw.dataBaseManager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.example.qxfw.common.entity.JgInfo;
import com.example.qxfw.common.entity.RoadlineType;
import com.example.qxfw.common.entity.TrafficHightwayPnt;
import com.example.qxfw.common.entity.TravelPredict;
import com.example.qxfw.common.entity.qx.SmallScaleStation;
import com.example.qxfw.common.entity.qx.TownshipStation;

import com.example.qxfw.common.entity.zy.EnviroStation;
import com.example.qxfw.common.entity.zy.TourStations;
import com.example.qxfw.common.entity.zy.TrafficWeatherSta;
import com.example.qxfw.common.mapper.*;
import com.example.qxfw.dataBaseManager.service.ProfessionalInformationService;

import com.example.qxfw.ybzz.mapper.TrafficWeatherStaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/8  星期六   15:48
 * @description : 此类用来
 ***************************************/
@Service
public class ProfessionalInformationServiceImpl implements ProfessionalInformationService {

    @Autowired
    private EnvirostationMapperXml envirostationMapperXml;

    @Autowired
    private SmallscaleStationMapperXml smallscaleStationMapperXml;

    @Autowired
    private TownshipStationMapperXml townshipStationMapperXml;

    @Autowired
    private TrafficHightwayPntMapperXml trafficHightwayPntMapperXml;

    @Autowired
    private RoadlineTypeMapperXml roadlineTypeMapperXml;

    @Autowired
    private JgInfoMapperXml jgInfoMapperXml;

    @Autowired
    private TourStationsMapperXml tourStationsMapperXml;

    @Autowired
    private TravelPredictMapperXml travelPredictMapperXml;

    @Autowired
    private TrafficWeatherStaMapper trafficWeatherStaMapper;

    @Override
    public List<EnviroStation> getEnviroStationRtrim() {
        List<EnviroStation> trim = envirostationMapperXml.getTrim();
        return trim;
    }

    @Override
    public List<EnviroStation> judgeEnviroStation(final String stationName) {
        return this.envirostationMapperXml.judgeSelect(stationName);
    }

    @Override
    public Integer saveEnviroStation(final EnviroStation envirostation) {
        return this.envirostationMapperXml.insertSelective(envirostation);
    }

    @Override
    public Integer deleteEnviroStation(final String stationName) {
        return this.envirostationMapperXml.deleteTrim(stationName);
    }

    @Override
    public Integer updateEnviroStation(final EnviroStation envirostation) {
        return this.envirostationMapperXml.updateByPrimaryKeySelective(envirostation);
    }

    @Override
    public List<EnviroStation> getAllnviroStation() {
        return this.envirostationMapperXml.selectList(null);
    }

    @Override
    public List<SmallScaleStation> getDistinctStationId() {
        return this.smallscaleStationMapperXml.selectData("distinct stationid", "smallscale_station", null, null, null);
    }

    @Override
    public List<TownshipStation> getDistinctStationIdByCityFromTownShipStation(final String city) {
        return this.townshipStationMapperXml.getDistinctByCity(city);
    }

    @Override
    public List<TrafficHightwayPnt> getTrafficHightwayPntOrderById() {
        return this.trafficHightwayPntMapperXml.selectList(new LambdaQueryWrapper<TrafficHightwayPnt>()
                .orderByAsc(TrafficHightwayPnt::getId));
    }

    @Override
    public List<TownshipStation> getTownShipStationByLongitude(final String city, final Double jd, final Double wd) {
        return this.townshipStationMapperXml.getByCity(city, jd, wd);
    }

    @Override
    public List<SmallScaleStation> getSmallScaleStationByLongitude(final String city, final Double jd, final Double wd) {
        return this.smallscaleStationMapperXml.getByLongItude(city, jd, wd);
    }

    @Override
    public List<TrafficHightwayPnt> getTrafficHightWayPntById(final Integer id) {
        return this.trafficHightwayPntMapperXml.selectList(new LambdaQueryWrapper<TrafficHightwayPnt>()
                .eq(TrafficHightwayPnt::getId, id));
    }

    @Override
    public Integer saveTrafficHightWayPnt(final TrafficHightwayPnt trafficHightwayPnt) {
        return this.trafficHightwayPntMapperXml.insertSelective(trafficHightwayPnt);
    }

    @Override
    public Integer updateTrafficHightWayPnt(final TrafficHightwayPnt trafficHightwayPnt) {
        return this.trafficHightwayPntMapperXml.updateByPrimaryKeySelective(trafficHightwayPnt);
    }

    @Override
    public Integer deleteTrafficHightWayPnt(final Integer id) {
        return this.trafficHightwayPntMapperXml.deleteById(id);
    }

    @Override
    public List<TrafficHightwayPnt> getTrafficHeightWayPntOrderById() {
        return this.trafficHightwayPntMapperXml.selectList(new LambdaQueryWrapper<TrafficHightwayPnt>()
                .orderByAsc(TrafficHightwayPnt::getId));
    }

    @Override
    public List<RoadlineType> getDistinctRoadTypeFromRoadLineType() {
        return this.roadlineTypeMapperXml.selectDistinct();
    }

    @Override
    public List<RoadlineType> getRoadLineTypeByRoadType(final String roadType) {
        return this.roadlineTypeMapperXml.selectList(new LambdaQueryWrapper<RoadlineType>()
                .eq(RoadlineType::getRoadtype, roadType));
    }

    @Override
    public Integer saveRoadLineType(final RoadlineType roadlineType) {
        return this.roadlineTypeMapperXml.insertSelective(roadlineType);
    }

    @Override
    public Integer updateRoadLineType(final RoadlineType roadlineType) {
        return this.roadlineTypeMapperXml.updateByPrimaryKeySelective(roadlineType);
    }

    @Override
    public Integer deleteRoadLineType(final String roadType) {
        return this.roadlineTypeMapperXml.deleteByPrimaryKey(roadType);
    }

    @Override
    public List<JgInfo> getRtrimNameFromJgInfo(final String name) {
        return jgInfoMapperXml.getRtrimName(name);
    }

    @Override
    public Integer saveJgInfo(final JgInfo jgInfo) {
        return this.jgInfoMapperXml.insertSelective(jgInfo);
    }

    @Override
    public Integer updateJgInfo(final JgInfo jgInfo) {
        return this.jgInfoMapperXml.updateByPrimaryKeySelective(jgInfo);
    }

    @Override
    public Integer deleteJgInfo(final String name) {
        return this.jgInfoMapperXml.deleteById(name);
    }

    @Override
    public List<TourStations> getTourStations() {
        return this.tourStationsMapperXml.selectList(null);
    }

    @Override
    public List<TourStations> getTourStationsByStationName(final String stationName) {
        return this.tourStationsMapperXml.selectList(new LambdaQueryWrapper<TourStations>()
                .eq(TourStations::getStationname, stationName));
    }

    @Override
    public Integer saveTourStations(final TourStations tourStations) {
        return this.tourStationsMapperXml.insertSelective(tourStations);
    }

    @Override
    public Integer updateTourStations(final TourStations tourStations) {
        return this.tourStationsMapperXml.updateByPrimaryKeySelective(tourStations);
    }

    @Override
    public Integer deleteTourStations(final String stationName) {
        return this.tourStationsMapperXml.deleteById(stationName);
    }

    @Override
    public List<TravelPredict> selectDistinctJqNameFromTravelPredict() {
        /*return this.travelPredictMapperXml.selectList(Wrappers.<TravelPredict>query()
//                .select("dis")
                .lambda()
                .select(TravelPredict::getJqname,TravelPredict::getLatitude));*/
        return this.travelPredictMapperXml.selectDistinctJqName();
    }

    @Override
    public List<TravelPredict> selectDistinctSpotNameFromTravelPredict() {
        return this.travelPredictMapperXml.selectDistinctSpotName();
    }

    @Override
    public List<TravelPredict> getAllTravelPredict() {
        return travelPredictMapperXml.selectList(null);
    }

    @Override
    public List<TravelPredict> queryTravelPredictLikeJqNameAndSpotName(String jqName,String spotName) {
        return this.travelPredictMapperXml.selectList(new LambdaQueryWrapper<TravelPredict>()
                .like(TravelPredict::getJqname, jqName)
                .like(TravelPredict::getSpotname, spotName));
    }

    @Override
    public List<TravelPredict> selectTravelPredictByJqnNameAndSpotName(final String jqName, final String spotName) {
        return this.travelPredictMapperXml.selectList(new LambdaQueryWrapper<TravelPredict>()
                .eq(TravelPredict::getJqname, jqName));
    }

    @Override
    public Integer saveTravelPredict(final TravelPredict travelPredict) {
        return this.travelPredictMapperXml.insertSelective(travelPredict);
    }

    @Override
    public Integer updateTravelPredict(final TravelPredict travelPredict) {
        return this.travelPredictMapperXml.updateByPrimaryKeySelective(travelPredict);
    }

    @Override
    public Integer clearTravelPredict() {
        return this.travelPredictMapperXml.clearTravelPredict();
    }

    @Override
    public List<TrafficWeatherSta> getTrafficWeatherStaOrderByStationId() {
        return this.trafficWeatherStaMapper.selectList(new LambdaQueryWrapper<TrafficWeatherSta>()
                .orderByAsc(TrafficWeatherSta::getStationid));
    }

    @Override
    public List<TrafficWeatherSta> getTrafficWeatherStaByStationId(final String stationId) {
        return this.trafficWeatherStaMapper.selectList(new LambdaQueryWrapper<TrafficWeatherSta>()
                .eq(TrafficWeatherSta::getStationid,stationId));
    }

    @Override
    public Integer saveTrafficWeatherSta(final TrafficWeatherSta trafficWeatherSta) {
        return this.trafficWeatherStaMapper.insert(trafficWeatherSta);
    }

    @Override
    public Integer updateTrafficWeatherSta(final TrafficWeatherSta trafficWeatherSta) {
        return this.trafficWeatherStaMapper.updateById(trafficWeatherSta);
    }

    @Override
    public Integer deleteTrafficWeatherSta(final String stationId) {
        return this.trafficWeatherStaMapper.deleteById(stationId);
    }

    @Override
    public List<TrafficWeatherSta> getAllTrafficWeatherSta() {
        return this.trafficWeatherStaMapper.selectList(null);
    }

    @Override
    public List<TrafficHightwayPnt> getAllTrafficHightWayPnt() {
        return this.trafficHightwayPntMapperXml.selectList(null);
    }
}
